<extend name="Public/common" />
<block name="style">
    <style type="text/css">
        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</block>
<block name="head">
    <title>首页</title>
</block>
<block name="body">
    <nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="{:U('Home/index/index')}">校企互动平台
                    <small>创业导师</small>
                </a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a href="#">创业资讯</a></li>
                    <li><a href="#">企业招募</a></li>
                    <li><a href="#">项目交易</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">

                    <?php if (is_login()) {
                        $uid=is_login();
                        if ($uid){
                            $user=query_user($uid);
                            $username=($user['username']);
                        }
                    ?>
                    <li>
                        <a id="logoffButton" href="javascript: logoff();"> <i class="fa fa-user-circle-o"></i> {$username}</a>
                    </li>
                    <?php } else {?>
                    <li>
                        <a href="{:U('login')}"> 登陆系统</a>
                    </li>
                    <?php }?>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-bars"></i></a>
                        <ul class="dropdown-menu">
                            <li><a href="#">用户中心</a></li>
                            <li><a href="#">发布项目</a></li>
                            <li><a href="#">申请认证</a></li>
                            <li><a href="#">我的收藏</a></li>
                            <li><a href="#">我的账户</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">后台管理</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>
    <div class="container-fluid">
        首页
    </div>
</block>
<block name="script">
    <script>
        function logoff() {
            $.ajax({
                type: "post",
                url: "{:U('logoff')}",
                data: '',
                success: function (response) {
                    alert(JSON.stringify(response));
                    const code = response.code;
                    if (code === 0) {
                        window.location = "{:U('index')}";
                        //正常执行，成功登陆
                    } else {
                        //表明出错,显示错误信息
                        alert(response.message);
                    }
                },
                error: function (response) {
                    alert(JSON.stringify(response));
                }
            });
        }
    </script>

</block>




